<template>
<div v-if="viewLoading" class="ivu-table-wrapper">
  <div class="ivu-table">
    <div class="ivu-table-body">
      <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <tbody class="ivu-table-tbody">
          <tr class="ivu-table-row">
            <td><div class="ivu-table-cell">进货用户名：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_buy.account }}</div></td>

            <td><div class="ivu-table-cell">进货手机号：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_buy.cellphone }}</div></td>
          </tr>

          <tr class="ivu-table-row">
            <td><div class="ivu-table-cell">进货订单号：</div></td>
            <td><div class="ivu-table-cell">{{ model.trade_buy.create_time }}</div></td>

            <td><div class="ivu-table-cell">进货数量：</div></td>
            <td><div class="ivu-table-cell">{{ model.trade_buy.amount }}</div></td>
          </tr>

          <tr class="ivu-table-row">
            <td><div class="ivu-table-cell">进货创建时间：</div></td>
            <td><div class="ivu-table-cell">{{ dayjs(model.trade_buy.create_time * 1000).format('YYYY-MM-DD HH:mm:ss') }}</div></td>

            <td><div class="ivu-table-cell" v-if="model.trade_buy.image.toString()!==''">进货凭证图片(点击打开)：</div></td>
            <td><div class="ivu-table-cell" v-if="model.trade_buy.image.toString()!==''"><a :href="this.config.uploadUrl+model.trade_buy.image" target="_blank"><img :src="this.config.uploadUrl+model.trade_buy.image" width="50" /></a></div></td>
          </tr>

          <tr class="ivu-table-row" v-if="model.trade_buy.trade_sell_id.toString()!=='0'">
            <td><div class="ivu-table-cell">销售订单号：</div></td>
            <td><div class="ivu-table-cell">{{ model.trade_sell.create_time }}</div></td>

            <td><div class="ivu-table-cell">销售数量：</div></td>
            <td><div class="ivu-table-cell">{{ model.trade_sell.amount }}</div></td>
          </tr>

          <tr class="ivu-table-row" v-if="model.trade_buy.trade_sell_id.toString()!=='0'">
            <td><div class="ivu-table-cell">销售创建时间：</div></td>
            <td><div class="ivu-table-cell">{{ dayjs(model.trade_sell.create_time * 1000).format('YYYY-MM-DD HH:mm:ss') }}</div></td>

            <td><div class="ivu-table-cell">销售推荐人手机号：</div></td>
            <td><div class="ivu-table-cell">{{ model.parent_user_sell.cellphone }}</div></td>
          </tr>

          <tr class="ivu-table-row" v-if="model.trade_buy.to_user_id.toString()!=='0'">
            <td><div class="ivu-table-cell">销售用户名：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_sell.account }}</div></td>

            <td><div class="ivu-table-cell">销售手机号：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_sell.cellphone }}</div></td>
          </tr>

          <tr class="ivu-table-row" v-if="model.trade_buy.trade_sell_id.toString()!=='0'">
            <td><div class="ivu-table-cell">销售真实姓名：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_bank_info.bank_name }}</div></td>

            <td><div class="ivu-table-cell">销售打款账号：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_bank_info.bank_account }}</div></td>
          </tr>

          <tr class="ivu-table-row" v-if="model.trade_buy.trade_sell_id.toString()!=='0'">
            <td><div class="ivu-table-cell">销售开户地址：</div></td>
            <td><div class="ivu-table-cell">{{ model.user_bank_info.bank_address_detail }}</div></td>

            <td><div class="ivu-table-cell">销售属性：</div></td>
            <td>
              <div class="ivu-table-cell">
              	<span v-if="model.user_bank_info.type.toString() == '1'">云支付</span>
      					<span v-else-if="model.user_bank_info.type.toString() == '2'">支付宝</span>
     						<span v-else-if="model.user_bank_info.type.toString() == '3'">银行卡</span>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
</template>

<script>
import dayjs from 'dayjs';
import ajaxiView from '@/utils/ajaxiView';
import auth from '@/utils/auth';
import config from '@/config';

export default {
  props: ['tradeBuyId'],
  data() {
    return {
      config,
      dayjs,
      model: {},
      viewLoading: false,
      token: auth.getToken()
    };
  },
  methods: {
    getData() {
      let _this = this;
      ajaxiView.get('/backstage/trade/buy/' + this.$props.tradeBuyId + '?token='+_this.token).then(function(data) {
        if(data !== false && typeof(data.trade_buy) != 'undefined') {
          _this.model = data;
          console.log(_this.model);

          _this.viewLoading = true;
        }
      });
    }
  },
  mounted() {
    this.getData();
  }
};

</script>
